import Vue from 'vue'
import VueRouter from 'vue-router'


Vue.use(VueRouter)
//路由表
const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login')
  },
  {
    path: '/',
    component: () => import('@/views/layout'),
    //子路由
    children: [
      {
        path: '/home',
        name: 'home',
        component: () => import('@/views/home'),
        children: [
          {
            path: '/home/searchPopup',
            name: 'SearchPopup',
            component: () => import('@/views/home/SearchPopup.vue')
          },
        ]
      },

      {
        path: '/fenglei',
        name: 'fenglei',
        component: () => import('@/views/fenglei')
      },
      {
        path: '/shop',
        name: 'shop',
        component: () => import('@/views/shop')
      },
      {
        path: '/my',
        name: 'my',
        component: () => import('@/views/my')
      },
    ]
  }

]
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
